<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MsgInfo extends Model
{
    protected $table = 'msg_info';
    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'update_time';
    protected $fillable = [
        'title', 'content', 'logo', 'type', 'detail', 'url', 'status', 'send_time', 'user_type','create_id'
    ];

    public static function getTypes(){
        return [
            1=>'系统通知',
            2=>'活动通知',
            3=>'账户通知',
            4=>'互动问答',
            5=>'物流助手',
        ];
    }
    /**
     * 获取消息类型配置
     * @param [type] $type
     * @method getTypeConfig
     * @author chengzhigang<1256699215@qq.com>
     */
    public static function getTypeConfig($type)
    {
        switch ($type) {
            case 1:
                return [
                    'type' => $type,
                    'title' => '系统通知',
                    'logo' => config('const.img_url') . '/static/app/image/system.png',
                ];
                break;
            case 2:
                return [
                    'type' => $type,
                    'title' => '活动通知',
                    'logo' => config('const.img_url') . '/static/image/activity.png',
                ];
                break;
            case 3:
                return [
                    'type' => $type,
                    'title' => '账户通知',
                    'logo' => config('const.img_url') . '/static/image/account.png',
                ];
                break;
            case 4:
                return [
                    'type' => $type,
                    'title' => '互动问答',
                    'logo' => config('const.img_url') . '/static/image/message.png',
                ];
                break;
            case 5:
                return [
                    'type' => $type,
                    'title' => '物流助手',
                    'logo' => config('const.img_url') . '/static/image/logistics.png',
                ];
                break;
        }
    }

    //消息发送状态
    public static function sendStatus($send_status){
        if($send_status==1){
            return '未发送';
        }elseif($send_status==2){
            return '已发送';
        }else{
            return '已删除';
        }
    }
    //发放群体
    public static function userStatus($user_status){
        if($user_status==1){
            return '全部用户';
        }else{
            return '部分用户';
        }
    }
}
